using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VMKRF
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                case "JLT":
                default:
                    #region====JLT======
                    dwReturn["MKFMANDANT"] = "00";
                    dwReturn["MKFMNRKRS"] = "  ";
                    dwReturn["MKFMLFDNR"] = "0000";
                    dwReturn["MKFMPOS"] = "01";
                    dwReturn["MKFLFDNR"] = "1";
                    dwReturn["MKFNEUB"] = "        ";
                    dwReturn["MKFNEUD"] = "0";
                    dwReturn["MKFAENB"] = "        ";
                    dwReturn["MKFAEND"] = "0";
                    dwReturn["MKFAENZL"] = "0";
                    dwReturn["MKFERLKZ"] = " ";
                    dwReturn["MKFERLDAT"] = "00000000";
                    dwReturn["MKFAUFKRS"] = "  ";
                    dwReturn["MKFAUFLFD"] = "000000";
                    dwReturn["MKFAUFPOS"] = "000";
                    dwReturn["MKFAFOLGE"] = "000";
                    dwReturn["MKFTP"] = "0000";
                    dwReturn["MKFRWKRS"] = "  ";
                    dwReturn["MKFRWLFD"] = "000000";
                    dwReturn["MKFRWPOS"] = "0000";
                    dwReturn["MKFPLDATV"] = "0";
                    dwReturn["MKFSCHICHTV"] = "0";
                    dwReturn["MKFPLDATB"] = "0";
                    dwReturn["MKFSCHICHTB"] = "0";
                    dwReturn["MKFRFKZ"] = " ";
                    dwReturn["MKFRUESTZT"] = "0";
                    dwReturn["MKFBEARBZT"] = "0";
                    dwReturn["MKFSME"] = "5";
                    dwReturn["MKFSMG1"] = "0";
                    dwReturn["MKFSMG2"] = "0";
                    dwReturn["MKFSMG3"] = "0";
                    dwReturn["MKFSMG4"] = "0";
                    dwReturn["MKFSMG5"] = "0";
                    dwReturn["MKFSMG6"] = "0";
                    dwReturn["MKFSMG7"] = "0";
                    dwReturn["MKFSMG8"] = "0";
                    dwReturn["MKFAUTO"] = " ";
                    dwReturn["MKFBFARBE1"] = "0";
                    dwReturn["MKFBFARBE2"] = "0";
                    dwReturn["MKFBFARBE3"] = "0";
                    dwReturn["MKFBFARBE4"] = "0";
                    dwReturn["MKFBFARBE5"] = "0";
                    dwReturn["MKFBFARBE6"] = "0";
                    dwReturn["MKFBFARBE7"] = "0";
                    dwReturn["MKFBFARBE8"] = "0";
                    dwReturn["MKFBFARBE9"] = "0";
                    dwReturn["MKFBFARBE10"] = "0";
                    dwReturn["MKFSORTFD1"] = "                                                                           ";
                    dwReturn["MKFSORTFD2"] = "                                                                           ";
                    dwReturn["MKFSORTFD3"] = "                                                                           ";
                    dwReturn["MKFPLSTUFE"] = " ";
                    dwReturn["MKFBDEDAT"] = "0";
                    dwReturn["MKFBDEZT"] = "0";
                    dwReturn["MKFBDEBEN"] = "        ";
                    dwReturn["MKFRGBWERT1"] = "000";
                    dwReturn["MKFRGBWERT2"] = "000";
                    dwReturn["MKFRGBWERT3"] = "000";
                    dwReturn["MKFFRBH"] = "000";
                    dwReturn["MKFFLAG"] = "0";
                    dwReturn["MKFSETQF1"] = "  ";
                    dwReturn["MKFNUMKZ1"] = " ";
                    dwReturn["MKFWERT1"] = "                ";
                    dwReturn["MKFCODE1"] = "   ";
                    dwReturn["MKFTIME1"] = "0";
                    dwReturn["MKFSETQF2"] = "  ";
                    dwReturn["MKFNUMKZ2"] = " ";
                    dwReturn["MKFWERT2"] = "                ";
                    dwReturn["MKFCODE2"] = "   ";
                    dwReturn["MKFTIME2"] = "0";
                    dwReturn["MKFSETQF3"] = "  ";
                    dwReturn["MKFNUMKZ3"] = " ";
                    dwReturn["MKFWERT3"] = "                ";
                    dwReturn["MKFCODE3"] = "   ";
                    dwReturn["MKFTIME3"] = "0";
                    dwReturn["MKFSETQF4"] = "  ";
                    dwReturn["MKFNUMKZ4"] = " ";
                    dwReturn["MKFWERT4"] = "                ";
                    dwReturn["MKFCODE4"] = "   ";
                    dwReturn["MKFTIME4"] = "0";
                    dwReturn["MKFSETQF5"] = "  ";
                    dwReturn["MKFNUMKZ5"] = " ";
                    dwReturn["MKFWERT5"] = "                ";
                    dwReturn["MKFCODE5"] = "   ";
                    dwReturn["MKFTIME5"] = "0";
                    dwReturn["MKFSETQF6"] = "  ";
                    dwReturn["MKFNUMKZ6"] = " ";
                    dwReturn["MKFWERT6"] = "                ";
                    dwReturn["MKFCODE6"] = "   ";
                    dwReturn["MKFTIME6"] = "0";
                    dwReturn["MKFSETQF7"] = "  ";
                    dwReturn["MKFNUMKZ7"] = " ";
                    dwReturn["MKFWERT7"] = "                ";
                    dwReturn["MKFCODE7"] = "   ";
                    dwReturn["MKFTIME7"] = "0";
                    dwReturn["MKFSETQF8"] = "  ";
                    dwReturn["MKFNUMKZ8"] = " ";
                    dwReturn["MKFWERT8"] = "                ";
                    dwReturn["MKFCODE8"] = "   ";
                    dwReturn["MKFTIME8"] = "0";
                    dwReturn["MKFSETQF9"] = "  ";
                    dwReturn["MKFNUMKZ9"] = " ";
                    dwReturn["MKFWERT9"] = "                ";
                    dwReturn["MKFCODE9"] = "   ";
                    dwReturn["MKFTIME9"] = "0";
                    dwReturn["MKFSETQF10"] = "  ";
                    dwReturn["MKFNUMKZ10"] = " ";
                    dwReturn["MKFWERT10"] = "                ";
                    dwReturn["MKFCODE10"] = "   ";
                    dwReturn["MKFTIME10"] = "0";
                    dwReturn["MKFMODNR"] = "000";
                    dwReturn["MKFEINSTNR"] = "000";
                    dwReturn["MKFPROG"] = "                ";
                    dwReturn["MKFREZST"] = "0";
                    dwReturn["MKFBEZ"] = "                              ";
                    dwReturn["MKFCLTIME"] = "0";
                    dwReturn["MKFHARCHA"] = " ";
                    dwReturn["MKFKZHCMAN"] = " ";
                    dwReturn["MKFNBWCHA"] = "00";
                    dwReturn["MKFMAUFKRS"] = "  ";
                    dwReturn["MKFMAUFLFD"] = "000000";
                    dwReturn["MKFMAUFPOS"] = "000";
                    dwReturn["MKFMAFOLGE"] = "000";
                    dwReturn["MKFMTP"] = "0000";
                    dwReturn["MKFVMNRKRS"] = "  ";
                    dwReturn["MKFVMLFDNR"] = "0000";
                    dwReturn["MKFVMPOS"] = "00";
                    dwReturn["MKFSDATF"] = "0";
                    dwReturn["MKFSZEITF"] = "0";
                    dwReturn["MKFSDATE"] = "0";
                    dwReturn["MKFSZEITE"] = "0";
                    dwReturn["MKFSDATB"] = "0";
                    dwReturn["MKFSZEITB"] = "0";
                    dwReturn["MKFEDAT"] = "0";
                    dwReturn["MKFEZEIT"] = "0";
                    dwReturn["MKFGRQM"] = "0";
                    dwReturn["MKFMENGE"] = "0";
                    dwReturn["MKFKZPOSVERT"] = " ";
                    dwReturn["MKFKETTANZ"] = "0";
                    dwReturn["MKFKETTMTR"] = "0";
                    dwReturn["MKFVORPL"] = " ";
                    dwReturn["MKFDISPO2"] = " ";
                    dwReturn["MKFBEM"] = "                                        ";
                    dwReturn["MKFFILLER"] = "                                                                            ";
                    #endregion
                    break;
            }
        }
        public DataRow Convert2MKRF(DataRow dwInput, string ITXDBVERSION, bool IsConvert = false)
        {
            DataSet SResult = new DataSet();
            SResult = QueryMKRF(dwInput, 0);
            DataRow dwReturn = null;
            if (SResult.Tables[0].Rows.Count > 0)
            {
                dwReturn = SResult.Tables[0].Rows[0];
            }
            else
            {
                dwReturn = SResult.Tables[0].NewRow();
            }
            switch (ITXDBVERSION)
            {
                case "YGR":
                case "JLT":
                default:
                    #region====JLT======
                    dwReturn["MKFMANDANT"] = "00";
                    dwReturn["MKFMNRKRS"] = "  ";
                    dwReturn["MKFMLFDNR"] = "0000";
                    dwReturn["MKFMPOS"] = "01";
                    dwReturn["MKFLFDNR"] = "1";
                    dwReturn["MKFNEUB"] = "        ";
                    dwReturn["MKFNEUD"] = "0";
                    dwReturn["MKFAENB"] = "        ";
                    dwReturn["MKFAEND"] = "0";
                    dwReturn["MKFAENZL"] = "0";
                    dwReturn["MKFERLKZ"] = " ";
                    dwReturn["MKFERLDAT"] = "00000000";
                    dwReturn["MKFAUFKRS"] = "  ";
                    dwReturn["MKFAUFLFD"] = "000000";
                    dwReturn["MKFAUFPOS"] = "000";
                    dwReturn["MKFAFOLGE"] = "000";
                    dwReturn["MKFTP"] = "0000";
                    dwReturn["MKFRWKRS"] = "  ";
                    dwReturn["MKFRWLFD"] = "000000";
                    dwReturn["MKFRWPOS"] = "0000";
                    dwReturn["MKFPLDATV"] = "0";
                    dwReturn["MKFSCHICHTV"] = "0";
                    dwReturn["MKFPLDATB"] = "0";
                    dwReturn["MKFSCHICHTB"] = "0";
                    dwReturn["MKFRFKZ"] = " ";
                    dwReturn["MKFRUESTZT"] = "0";
                    dwReturn["MKFBEARBZT"] = "0";
                    dwReturn["MKFSME"] = "5";
                    dwReturn["MKFSMG1"] = "0";
                    dwReturn["MKFSMG2"] = "0";
                    dwReturn["MKFSMG3"] = "0";
                    dwReturn["MKFSMG4"] = "0";
                    dwReturn["MKFSMG5"] = "0";
                    dwReturn["MKFSMG6"] = "0";
                    dwReturn["MKFSMG7"] = "0";
                    dwReturn["MKFSMG8"] = "0";
                    dwReturn["MKFAUTO"] = " ";
                    dwReturn["MKFBFARBE1"] = "0";
                    dwReturn["MKFBFARBE2"] = "0";
                    dwReturn["MKFBFARBE3"] = "0";
                    dwReturn["MKFBFARBE4"] = "0";
                    dwReturn["MKFBFARBE5"] = "0";
                    dwReturn["MKFBFARBE6"] = "0";
                    dwReturn["MKFBFARBE7"] = "0";
                    dwReturn["MKFBFARBE8"] = "0";
                    dwReturn["MKFBFARBE9"] = "0";
                    dwReturn["MKFBFARBE10"] = "0";
                    dwReturn["MKFSORTFD1"] = "                                                                           ";
                    dwReturn["MKFSORTFD2"] = "                                                                           ";
                    dwReturn["MKFSORTFD3"] = "                                                                           ";
                    dwReturn["MKFPLSTUFE"] = "W";
                    dwReturn["MKFBDEDAT"] = "0";
                    dwReturn["MKFBDEZT"] = "0";
                    dwReturn["MKFBDEBEN"] = "        ";
                    dwReturn["MKFRGBWERT1"] = "000";
                    dwReturn["MKFRGBWERT2"] = "000";
                    dwReturn["MKFRGBWERT3"] = "000";
                    dwReturn["MKFFRBH"] = "000";
                    dwReturn["MKFFLAG"] = "0";
                    dwReturn["MKFSETQF1"] = "  ";
                    dwReturn["MKFNUMKZ1"] = " ";
                    dwReturn["MKFWERT1"] = "                ";
                    dwReturn["MKFCODE1"] = "   ";
                    dwReturn["MKFTIME1"] = "0";
                    dwReturn["MKFSETQF2"] = "  ";
                    dwReturn["MKFNUMKZ2"] = " ";
                    dwReturn["MKFWERT2"] = "                ";
                    dwReturn["MKFCODE2"] = "   ";
                    dwReturn["MKFTIME2"] = "0";
                    dwReturn["MKFSETQF3"] = "  ";
                    dwReturn["MKFNUMKZ3"] = " ";
                    dwReturn["MKFWERT3"] = "                ";
                    dwReturn["MKFCODE3"] = "   ";
                    dwReturn["MKFTIME3"] = "0";
                    dwReturn["MKFSETQF4"] = "  ";
                    dwReturn["MKFNUMKZ4"] = " ";
                    dwReturn["MKFWERT4"] = "                ";
                    dwReturn["MKFCODE4"] = "   ";
                    dwReturn["MKFTIME4"] = "0";
                    dwReturn["MKFSETQF5"] = "  ";
                    dwReturn["MKFNUMKZ5"] = " ";
                    dwReturn["MKFWERT5"] = "                ";
                    dwReturn["MKFCODE5"] = "   ";
                    dwReturn["MKFTIME5"] = "0";
                    dwReturn["MKFSETQF6"] = "  ";
                    dwReturn["MKFNUMKZ6"] = " ";
                    dwReturn["MKFWERT6"] = "                ";
                    dwReturn["MKFCODE6"] = "   ";
                    dwReturn["MKFTIME6"] = "0";
                    dwReturn["MKFSETQF7"] = "  ";
                    dwReturn["MKFNUMKZ7"] = " ";
                    dwReturn["MKFWERT7"] = "                ";
                    dwReturn["MKFCODE7"] = "   ";
                    dwReturn["MKFTIME7"] = "0";
                    dwReturn["MKFSETQF8"] = "  ";
                    dwReturn["MKFNUMKZ8"] = " ";
                    dwReturn["MKFWERT8"] = "                ";
                    dwReturn["MKFCODE8"] = "   ";
                    dwReturn["MKFTIME8"] = "0";
                    dwReturn["MKFSETQF9"] = "  ";
                    dwReturn["MKFNUMKZ9"] = " ";
                    dwReturn["MKFWERT9"] = "                ";
                    dwReturn["MKFCODE9"] = "   ";
                    dwReturn["MKFTIME9"] = "0";
                    dwReturn["MKFSETQF10"] = "  ";
                    dwReturn["MKFNUMKZ10"] = " ";
                    dwReturn["MKFWERT10"] = "                ";
                    dwReturn["MKFCODE10"] = "   ";
                    dwReturn["MKFTIME10"] = "0";
                    dwReturn["MKFMODNR"] = "000";
                    dwReturn["MKFEINSTNR"] = "000";
                    dwReturn["MKFPROG"] = "                ";
                    dwReturn["MKFREZST"] = "0";
                    dwReturn["MKFBEZ"] = "                              ";
                    dwReturn["MKFCLTIME"] = "0";
                    dwReturn["MKFHARCHA"] = " ";
                    dwReturn["MKFKZHCMAN"] = " ";
                    dwReturn["MKFNBWCHA"] = "00";
                    dwReturn["MKFMAUFKRS"] = "  ";
                    dwReturn["MKFMAUFLFD"] = "000000";
                    dwReturn["MKFMAUFPOS"] = "000";
                    dwReturn["MKFMAFOLGE"] = "000";
                    dwReturn["MKFMTP"] = "0000";
                    dwReturn["MKFVMNRKRS"] = "  ";
                    dwReturn["MKFVMLFDNR"] = "0000";
                    dwReturn["MKFVMPOS"] = "00";
                    dwReturn["MKFSDATF"] = "0";
                    dwReturn["MKFSZEITF"] = "0";
                    dwReturn["MKFSDATE"] = "0";
                    dwReturn["MKFSZEITE"] = "0";
                    dwReturn["MKFSDATB"] = "0";
                    dwReturn["MKFSZEITB"] = "0";
                    dwReturn["MKFEDAT"] = "0";
                    dwReturn["MKFEZEIT"] = "0";
                    dwReturn["MKFGRQM"] = "0";
                    dwReturn["MKFMENGE"] = "0";
                    dwReturn["MKFKZPOSVERT"] = " ";
                    dwReturn["MKFKETTANZ"] = "0";
                    dwReturn["MKFKETTMTR"] = "0";
                    dwReturn["MKFVORPL"] = " ";
                    dwReturn["MKFDISPO2"] = " ";
                    dwReturn["MKFBEM"] = "                                        ";
                    dwReturn["MKFFILLER"] = "                                                                            ";
                    #endregion
                    break;
            }
            if (IsConvert)
            {
                foreach (DataColumn cm in dwInput.Table.Columns)
                {
                    if (dwInput[cm.ColumnName].ToString() == "")
                        continue;
                    if (dwInput.Table.Columns.Contains(cm.ColumnName))
                    {
                        dwReturn[cm.ColumnName] = dwInput[cm.ColumnName];
                    }
                }
            }
            return dwReturn;
        }
        public void SaveMKRF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            switch (ITXDBVERSION)
            {
                case "JLT":
                    setResult = QueryMKRF(dwData, 1);
                    if (setResult.Tables.Count > 0)
                    {
                        tbLocal = setResult.Tables[0];
                        if (tbLocal.Rows.Count > 0)
                        {
                            flgExist = true;
                            dwLocal = tbLocal.Rows[0];
                        }
                        else
                        {
                            dwLocal = tbLocal.NewRow();
                        }
                    }
                    MapMKRF(ref dwLocal, dwData);
                    if (!flgExist)
                    {
                        InsertMKRF(dwLocal, 1);
                    }
                    UpdateMKRF(dwLocal, 1);
                    break;
                case "YGR":
                    setResult = QueryMKRF(dwData, 1);
                    if (setResult.Tables.Count > 0)
                    {
                        tbLocal = setResult.Tables[0];
                        if (tbLocal.Rows.Count > 0)
                        {
                            flgExist = true;
                            dwLocal = tbLocal.Rows[0];
                        }
                        else
                        {
                            dwLocal = tbLocal.NewRow();
                        }
                    }
                    MapMKRF(ref dwLocal, dwData);
                    if (!flgExist)
                    {
                        InsertMKRF(dwLocal, 2);
                    }
                    UpdateMKRF(dwLocal, 2);
                    break;
                default:
                    break;
            }
        }
        public void MapMKRF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void DeleteMKRF(DataRow dwData, int option = 1)
        {

            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM MKRF WHERE ABAID=:MKFBEM";
                    or1.Parameters.Add("MKFBEM", OracleType.NVarChar).Value = dwData["MKFBEM"].ToString();
                    break;
                case 2:
                    or1.CommandText = "DELETE FROM MKRF T WHERE EXISTS (SELECT 1 FROM ICC_MKRF M WHERE T.MKFAUFKRS=M.ABFAUFKRS AND T.MKFAUFLFD=M.ABFAUFLFD AND T.MKFAUFPOS=M.ABFAUFPOS AND M.MKFERLKZ=:MKFERLKZ)";
                    or1.Parameters.Add("MKFERLKZ", OracleType.NVarChar).Value = dwData["MKFERLKZ"].ToString();
                    break;
                default:
                    break;
            }

            Connect2Proxy(or1);
        }
        public DataSet QueryMKRF(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM MKRF WHERE  ROWNUM<2 ";
                    SResult = Connect2Proxy(or1);
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM MKRF"
                        + "  WHERE MKFMANDANT=:MKFMANDANT: AND  MKFAUFKRS=:MKFAUFKRS: AND MKFAUFLFD=:MKFAUFLFD: AND MKFAUFPOS=:MKFAUFPOS: AND MKFAFOLGE=:MKFAFOLGE: AND MKFTP=:MKFTP:  ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    SResult = Connect2Proxy(or1);
                    break;
                case 2:
                    or1.CommandText = "SELECT M.* FROM MKRF M LEFT JOIN AMSTAMM S"
                        + " ON M.MKFMANDANT=S.AMMANDANT AND M.MKFMNRKRS=S.AMNRKRS AND M.MKFMLFDNR=S.AMLFDNR AND M.MKFMPOS=S.AMPOS"
                        + " LEFT JOIN KSTSTELL K ON S.AMMANDANT=K.KSTMANDANT AND S.AMKSTKRS=K.KSTKSTKRS AND S.AMKST=K.KSTKST"
                        + "  WHERE KSTMANDANT=:KSTMANDANT: AND KSTKSTKRS=:KSTKSTKRS: AND KSTKST=:KSTKST: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    SResult = Connect2Proxy(or1);
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM MKRF"
                        + "  WHERE MKFMANDANT=:MKFMANDANT: AND MKFAUFKRS=:MKFAUFKRS: AND MKFAUFLFD=:MKFAUFLFD: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    SResult = Connect2Proxy(or1);
                    break;
                default:
                    break;
            }
            SResult.Tables[0].TableName = "MKRF";
            return SResult;
        }
        public DataSet QMKRF04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT nvl(MAX(MKFLFDNR),'1') AS MKFLFDNR FROM MKRF"
                   + "  WHERE  MKFMANDANT=:MKFMANDANT: AND MKFMNRKRS=:MKFMNRKRS: AND MKFMLFDNR=:MKFMLFDNR: AND MKFMPOS=:MKFMPOS: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void UpdateMKRF(DataRow dwData, int option)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                default:
                    or1.CommandText = "UPDATE MKRF SET MKFMANDANT=:MKFMANDANT:,MKFMNRKRS=:MKFMNRKRS:,MKFMLFDNR=:MKFMLFDNR:,MKFMPOS=:MKFMPOS:,MKFLFDNR=:MKFLFDNR:,MKFNEUB=:MKFNEUB:,MKFNEUD=:MKFNEUD:,MKFAENB=:MKFAENB:,MKFAEND=:MKFAEND:,MKFAENZL=:MKFAENZL:,MKFERLKZ=:MKFERLKZ:,MKFERLDAT=:MKFERLDAT:,MKFAUFKRS=:MKFAUFKRS:,MKFAUFLFD=:MKFAUFLFD:,MKFAUFPOS=:MKFAUFPOS:,MKFAFOLGE=:MKFAFOLGE:,MKFTP=:MKFTP:,MKFRWKRS=:MKFRWKRS:,MKFRWLFD=:MKFRWLFD:,MKFRWPOS=:MKFRWPOS:,MKFPLDATV=:MKFPLDATV:,MKFSCHICHTV=:MKFSCHICHTV:,MKFPLDATB=:MKFPL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LFDNR=:MKFVMLFDNR:,MKFVMPOS=:MKFVMPOS:,MKFSDATF=:MKFSDATF:,MKFSZEITF=:MKFSZEITF:,MKFSDATE=:MKFSDATE:,MKFSZEITE=:MKFSZEITE:,MKFSDATB=:MKFSDATB:,MKFSZEITB=:MKFSZEITB:,MKFEDAT=:MKFEDAT:,MKFEZEIT=:MKFEZEIT:,MKFGRQM=:MKFGRQM:,MKFMENGE=:MKFMENGE:,MKFKZPOSVERT=:MKFKZPOSVERT:,MKFKETTANZ=:MKFKETTANZ:,MKFKETTMTR=:MKFKETTMTR:,MKFVORPL=:MKFVORPL:,MKFDISPO2=:MKFDISPO2:,MKFBEM=:MKFBEM:,MKFFILLER=:MKFFILLER:"
                        + "  WHERE MKFMANDANT=:MKFMANDANT: AND MKFMNRKRS=:MKFMNRKRS: AND MKFMLFDNR=:MKFMLFDNR: AND MKFMPOS=:MKFMPOS: AND MKFAUFKRS=:MKFAUFKRS: AND MKFAUFLFD=:MKFAUFLFD: AND MKFAUFPOS=:MKFAUFPOS: AND MKFAFOLGE=:MKFAFOLGE:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public void UMKRF02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE MKRF SET MKFERLKZ=:MKFERLKZ:,MKFERLDAT=:MKFERLDAT:"
                  + "  WHERE MKFMANDANT=:MKFMANDANT: AND MKFMNRKRS=:MKFMNRKRS: AND MKFMLFDNR=:MKFMLFDNR: AND MKFMPOS=:MKFMPOS: AND MKFAUFKRS=:MKFAUFKRS: AND MKFAUFLFD=:MKFAUFLFD: AND MKFAUFPOS=:MKFAUFPOS: AND MKFAFOLGE=:MKFAFOLGE:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
        }
        public void InsertMKRF(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                case "JLT":
                default:
                    or1.CommandText = "INSERT INTO MKRF ( MKFMANDANT,MKFMNRKRS,MKFMLFDNR,MKFMPOS,MKFLFDNR,MKFNEUB,MKFNEUD,MKFAENB,MKFAEND,MKFAENZL,MKFERLKZ,MKFERLDAT,MKFAUFKRS,MKFAUFLFD,MKFAUFPOS,MKFAFOLGE,MKFTP,MKFRWKRS,MKFRWLFD,MKFRWPOS,MKFPLDATV,MKFSCHICHTV,MKFPLDATB,MKFSCHICHTB,MKFRFKZ,MKFRUESTZT,MKFBEARBZT,MKFSME,MKFSMG1,MKFSMG2,MKFSMG3,MKFSMG4,MKFSMG5,MKFSMG6,MKFSMG7,MKFSMG8,MKFAUTO,MKFBFARBE1,MKFBFARBE2,MKFBFARBE3,MKFBFARBE4,MKFBFARBE5,MKFBFARBE6,MKFBFARBE7,MKFBFARBE8,MKFBFARBE9,MKFBFARBE10,MKFSORTFD1,MKFSORTFD2,MKFSORTFD3,MKFPLSTUFE,MKFBDEDAT,MKFBDEZT,MKFBDEBEN,MKFRGBWERT1,MKFRGBWERT2,MKFRGBWERT3,MKFFRBH,MKFFLAG,MKFSETQF1,MKFNUMKZ1,MKFWERT1,MKFCODE1,MKFTIME1,MKFSETQF2,MKFNUMKZ2,MKFWERT2,MKFCODE2,MKFTIME2,MKFSETQF3,MKFNUMKZ3,MKFWERT3,MKFCODE3,MKFTIME3,MKFSETQF4,MKFNUMKZ4,MKFWERT4,MKFCODE4,MKFTIME4,MKFSETQF5,MKFNUMKZ5,MKFWERT5,MKFCODE5,MKFTIME5,MKFSETQF6,MKFNUMKZ6,MKFWERT6,MKFCODE6,MKFTIME6,MKFSETQF7,MKFNUMKZ7,MKFWERT7,MKFCODE7,MKFTIME7,MKFSETQF8,MKFNUMKZ8,MKFWERT8,MKFCODE8,MKFTIME8,MKFSETQF9,MKFNUMKZ9,MKFWERT9,MKFCODE9,MKFTIME9,MKFSETQF10,MKFNUMKZ10,MKFWERT10,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T1:,:MKFCODE1:,:MKFTIME1:,:MKFSETQF2:,:MKFNUMKZ2:,:MKFWERT2:,:MKFCODE2:,:MKFTIME2:,:MKFSETQF3:,:MKFNUMKZ3:,:MKFWERT3:,:MKFCODE3:,:MKFTIME3:,:MKFSETQF4:,:MKFNUMKZ4:,:MKFWERT4:,:MKFCODE4:,:MKFTIME4:,:MKFSETQF5:,:MKFNUMKZ5:,:MKFWERT5:,:MKFCODE5:,:MKFTIME5:,:MKFSETQF6:,:MKFNUMKZ6:,:MKFWERT6:,:MKFCODE6:,:MKFTIME6:,:MKFSETQF7:,:MKFNUMKZ7:,:MKFWERT7:,:MKFCODE7:,:MKFTIME7:,:MKFSETQF8:,:MKFNUMKZ8:,:MKFWERT8:,:MKFCODE8:,:MKFTIME8:,:MKFSETQF9:,:MKFNUMKZ9:,:MKFWERT9:,:MKFCODE9:,:MKFTIME9:,:MKFSETQF10:,:MKFNUMKZ10:,:MKFWERT10:,:MKFCODE10:,:MKFTIME10:,:MKFMODNR:,:MKFEINSTNR:,:MKFPROG:,:MKFREZST:,:MKFBEZ:,:MKFCLTIME:,:MKFHARCHA:,:MKFKZHCMAN:,:MKFNBWCHA:,:MKFMAUFKRS:,:MKFMAUFLFD:,:MKFMAUFPOS:,:MKFMAFOLGE:,:MKFMTP:,:MKFVMNRKRS:,:MKFVMLFDNR:,:MKFVMPOS:,:MKFSDATF:,:MKFSZEITF:,:MKFSDATE:,:MKFSZEITE:,:MKFSDATB:,:MKFSZEITB:,:MKFEDAT:,:MKFEZEIT:,:MKFGRQM:,:MKFMENGE:,:MKFKZPOSVERT:,:MKFKETTANZ:,:MKFKETTMTR:,:MKFVORPL:,:MKFDISPO2:,:MKFBEM:,:MKFFILLER:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
            }
            Connect2Proxy(or1);
        }
    }
}
